import { _decorator, Color, Component, NodeEventType, Sprite, UITransform } from 'cc';
import { EventMgr } from '../../framework/manager/EventMgr';
import { EventName } from '../config/Config';
const { ccclass, property } = _decorator;

@ccclass('BgBlock')
export class BgBlock extends Component {
    x:number;
    y:number;
    start() {
        this.node.onEvent(NodeEventType.TOUCH_START,this.onClickNode,this)
        // this.node.active = false
    }
    init(x:number,y:number){
        this.x = x;
        this.y = y;
        return this
    }
    onTouchStart(value,event,v1,v2){
        console.log("onTouchStart",value,event,v1,v2) 
    }
    setSize(w,h){
        this.node.getComponent(UITransform).width = w;
        this.node.getComponent(UITransform).height = h;
        return this;
    }
    setColor(color:string){
        this.node.getComponent(Sprite).color = new Color().fromHEX(color);
        return this;
    }
    onClickNode(){
        EventMgr.getInstance().emit(EventName.CLICK_COLOR_BLOCK,this.y,this.x)
        
    }
    protected onDisable(): void {
    }
}


